package com.bwie.home.backstage.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.home.common.utils.PageUtils;
import com.bwie.home.common.utils.Query;

import com.bwie.home.backstage.dao.HousesDynamicDao;
import com.bwie.home.backstage.entity.HousesDynamicEntity;
import com.bwie.home.backstage.service.HousesDynamicService;


@Service("housesDynamicService")
public class HousesDynamicServiceImpl extends ServiceImpl<HousesDynamicDao, HousesDynamicEntity> implements HousesDynamicService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<HousesDynamicEntity> page = this.page(
                new Query<HousesDynamicEntity>().getPage(params),
                new QueryWrapper<>()
        );

        return new PageUtils(page);
    }
    @Override
    public PageUtils DynamicList(Map<String, Object> params) {
        IPage<HousesDynamicEntity> page = null;
        Integer pageIndex = 1;
        Integer pageSize =2;
        if(params!=null){
            //如果不为空赋值 pageIndex  pageSize
            if( params.get("pageIndex")!=null &&  (Integer)params.get("pageIndex")>0 &&  params.get("pageSize")!=null && (Integer) params.get("pageSize")>0){
                pageIndex = (Integer)params.get("pageIndex");
                pageSize = (Integer) params.get("pageSize");
            }
            //为空走默认
            Page<HousesDynamicEntity> Dynamic =
                    new Page<>(pageIndex, pageSize);
            page = baseMapper.HousesDynamic(Dynamic,Integer.parseInt(params.get("getdongtaiId").toString()));
        }
        assert page != null;
        return new PageUtils(page);
    }

}